package com.my.consumer.rpc.fallback;

import com.my.common.R;
import com.my.consumer.entiry.Girl;
import com.my.consumer.rpc.GirlClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: marshal
 * @date: 2021-07-14 2:19 PM
 */
@Component
@Slf4j
public class GirlFallback implements FallbackFactory<GirlClient> {

    public GirlClient create(Throwable cause) {
        StringBuilder sb = new StringBuilder();
        sb.append("\n\n系统:").append("producer");
        sb.append("\n\n错误类型：").append("系统熔断");
        sb.append("\n\n错误信息：").append(cause.getMessage());
        log.error(sb.toString());
        return new GirlClient() {

            public R<Girl> save(Girl girl) {
                return R.failed();
            }

            public R<Girl> query(int id) {
                return  R.failed();
            }
        };
    }
}
